import router from "@/router";
const goods = {
	state:{
		goodsList:[]
	},
	mutations:{
		ADD_GOODS(state,{goodsName,goodsPrice,success}){
			if(state.goodsList.some(v=>v.goodsName === goodsName)){
				alert("商品名称不允许重复！");
				return;
			}
			state.goodsList.unshift({
				goodsId:Math.random().toString(36).slice(2),
				goodsName,
				goodsPrice,
				addTime:Date.now()
			});
			success();
		}
	},
	getters:{

	}
};
export default goods;